package com.wt.struggle.goodbye.sq.adapter

import android.content.Context
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.LinearLayout
import com.wt.struggle.goodbye.R
import com.wt.struggle.goodbye.base.Config
import com.wt.struggle.goodbye.base.ProBaseAdapter
import com.wt.struggle.goodbye.info.NewsInfo
import com.xin.lv.yang.utils.utils.ImageUtil
import kotlinx.android.synthetic.main.classify_item.view.*

class QuClassifyAdapter(context: Context, list: ArrayList<NewsInfo>) : ProBaseAdapter<NewsInfo>(context, list) {

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        val vh = holder as VH
        val info = list[position]

        val w = (getW(context) - context.resources.getDimension(R.dimen.dp_20)) / 3

        vh.picFrameLayout.layoutParams = LinearLayout.LayoutParams(w.toInt(), w.toInt())
        vh.imageViewPic1.layoutParams = FrameLayout.LayoutParams(w.toInt(), w.toInt())

        ImageUtil.getInstance()
            .loadRoundCircleImage(context, vh.imageViewPic1, Config.GET_IMAGE_URL + info.icon, info.initRes, 4)

    }

    override fun onCreateView(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        return VH(inflater.inflate(R.layout.classify_item, parent, false))

    }

    override fun onUpdateHolder(holder: RecyclerView.ViewHolder, position: Int, payloads: MutableList<Any>) {

    }

    inner class VH(view: View) : RecyclerView.ViewHolder(view) {
        val imageViewPic1 = view.imageViewPic1
        val tvPicText1 = view.tvPicText1
        val tvText1Ms = view.tvText1Ms
        val picFrameLayout = view.picFrameLayout

    }
}